<?
class Category
{
	function Category($name, $price) { 
		$this->name = $name;
		$this->price = $price;
	}
	
	function name() { 
		return $this->name; 
	}
	
	function price() { 
		return $this->price; 
	}
	
//private:
	var $name;
   var $price;
};




class Categories {
	function Categories() {
	}
	
	function loadChildrenOf($id) {		//pass 0 for children of root
		$this->currCatId = $id;
		return false;
	}
	
	function reset() {}
	function current() {}
	function moveNext() {}
	
//private:
	var $currCatId;
	var $currCatChildren;
};




require_once('include/file.inc');

class LukumCategories extends Categories 
{
	function LukumCategories() {
		$this->Categories();
		$f = new File("price.html","r");
		$f->open();
		$contents = $f->getContents();
		$f->close();
		
		//load lukums
		$pattern = "/" .
		   "<tr bgcolor=#FFFFFF>\s*" .
		   "<td>(.*)<\/td>\s*" .
		   "<td>.*<strong>(.*)<\/strong><\/a><\/td>\s*" .
		   "<td>.*<\/td>\s*" .
		   "<td align=right>.*<\/td>\s*" .
		   "<td align=right>.*<\/td>\s*" .
		   "<td align=right>.*<\/td>\s*" .
		   "<td align=right>.*<\/td>\s*".
		   "<td align=right>(.*)<\/td>".
		   "/";
		preg_match_all($pattern, $contents, $matches, PREG_SET_ORDER);
		
		foreach ($matches as $match) {
		   $this->categories[] = new Category($match[1].' '.$match[2], $match[3]);
		}
		
		//load cookies
		$pattern = "/" .
		   "<tr bgcolor=#FFFFFF>\s*" .
		   "<td>.*<b>(.*)<\/b>.*<\/td>\s*" . 
		   "<td>(.*)<\/td>\s*<td>.*<\/td>\s*" .
		   "<td align=right>.*<\/td>\s*" .
		   "<td align=right>.*<\/td>\s*" .
		   "<td align=right>.*<\/td>\s*" .
		   "<td align=right.*>.*<\/td>\s*" .
		   "<td align=right.*>(.*)<\/td>" .
		   "/";
		preg_match_all($pattern, $contents, $matches, PREG_SET_ORDER);
		foreach ($matches as $match) {
			$this->categories[] = new Category($match[1].' '.$match[2], $match[3]);
		}

/*      echo "\n================================";
      print_r($this->categories);
      echo "\n================================";*/
	}
	
	function loadChildrenOf($id) {
		Categories::loadChildrenOf($id);
      return $this->reset();
	}
	
	function reset() {
	   return reset($this->categories);
	}
	
	function current() {
      return current($this->categories);
	}
	
	function moveNext() {
	   return next($this->categories);
   }	
	
//private:
	var $categories;
	var $currParentCat;
};


?>